<#include "/includes/vars.inc"> 
<@pp.dropOutputFile />
<#list embeddables.embeddable as embed>
	<#assign fileName = "${javaDir}${packageDir}/domain/embed/"+embed.@name+".java">
	<#if !pp.outputFileExists(fileName)>
		<@pp.changeOutputFile name="${fileName}" />
    	<#assign name = embed.@name>
package ${project.@rootPackage}.domain.embed;

<#list embed.column.@type as type>
    <#if enums.enum.@name?seq_contains(type)>
import ${project.@rootPackage}.domain.enums.${type};
    </#if>
</#list>    

import java.io.Serializable;
import javax.persistence.Embeddable;
import javax.persistence.Enumerated;
import javax.persistence.Column;
<#if embed?children.@type?seq_contains("Date")>
import java.util.Date;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
</#if>


/**
 * Embeddable class ${name}
 * <#if project.@author[0]??>@author ${project.@author}</#if>
 */
@Embeddable
public class ${name} implements Serializable{
        
    private static final long serialVersionUID = 1L;

    <#list embed.column as column>    
        <#if column.@type = "Date">
    @Column
    @Temporal(TemporalType.DATE)
        <#elseif enums.enum.@name?seq_contains(column.@type)>
    @Enumerated
        <#elseif column.@type="String" && column.@size[0]??  && (column.@size?number > 256) >
    @Lob
        <#else>
    @Column
        </#if>
    protected ${column.@type} ${column.@name};
    </#list>
	
   
    /*
    * GETTERS AND SETTERS
    */
    <#list embed.column as column>

    public void set${column.@name?cap_first}(${column.@type} ${column.@name}){
        this.${column.@name}=${column.@name};
    }    

    public ${column.@type} get${column.@name?cap_first}(){
        return ${column.@name};
    }
   
        <#if column.@type = "Boolean">
    public ${column.@type} is${column.@name?cap_first}(){
        return ${column.@name};
    }
        </#if>
    </#list>
        
     @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        <#if embed.@toString[0]??>
        	<#list embed.@toString?split(",") as col>
       	if (${col}!=null && !${col}.toString().isEmpty()){
       		sb.append(${col})<#if col_has_next>.append(" ");<#else>;</#if>
        }
        	</#list>	
        <#else>
        sb.append("${name}:");
        	<#list embed.column as column>    
        sb.append(" ${column.@name}:").append(${column.@name});
        	</#list>
        </#if>
        return sb.toString();
    }
   
}
	</#if>
</#list>
